package cn.lyd.config;

import cn.lyd.interceptor.LoginInterceptor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

//声明当前类是一个配置类
@Configuration
public class LoginConfig implements WebMvcConfigurer {
    @Autowired
    private LoginInterceptor loginInterceptor;
    //配置拦截器

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        //配置拦截器类
        registry.addInterceptor(loginInterceptor)
                //配置需要拦截的路径
                .addPathPatterns("/system/**")
                //配置需要放行的路径
                .excludePathPatterns("/system/register")
                .excludePathPatterns("/system/login");

        //如果拦截的/**
        /*registry.addInterceptor(loginInterceptor)
                //配置的是拦截所有 /**会拦截静态资源
                .addPathPatterns("/**")
                .excludePathPatterns("/system/login")
                .excludePathPatterns("/img/**")
                .excludePathPatterns("/min/**")
                .excludePathPatterns("/Scripts/**")
                .excludePathPatterns("/Styles/**")
                .excludePathPatterns("/Template/**")
                .excludePathPatterns("/chur-alert.1.0.js");*/

    }
}
